package com.ququ.syb.application.service;

import com.ququ.common.result.ResultJson;
import com.ququ.syb.application.redis.RedisDao;
import com.ququ.syb.common.constant.RedisKeyConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

@Service
public class ApplicationPermissionService {
    @Autowired
    private RedisDao redisDao;

    public ResultJson checkApplicationControllerAccessPermission(String controller,String appcode){
        Jedis jedis = redisDao.getJedis();
        try{
            if (jedis.sismember(RedisKeyConstant.APPLICATION_CONTROLLER+appcode,controller))
                return new ResultJson();
            else
                return new ResultJson(-1,"本应用无权访问此接口");
        }finally {
            redisDao.close(jedis);
        }
    }
}
